package com.gary.spring.controller;

import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author peng_rui
 * @date 2022/6/27
 */
@RestController
public class ScopeController {
    @Lazy
    @Resource
    private BeanForRequest beanForRequest;

    @Lazy
    @Resource
    private BeanForSession beanForSession;

    @Lazy
    @Resource
    private BeanForApplication beanForApplication;

    @RequestMapping(value = "/test", method = RequestMethod.GET, produces = "text/html")
    public String test() {
        StringBuilder sb = new StringBuilder();
        sb.append("<li> beanForRequest : ").append(beanForRequest).append("</li>");
        sb.append("<li> beanForSession : ").append(beanForSession).append("</li>");
        sb.append("<li> beanForApplication : ").append(beanForApplication).append("</li>");
        return sb.toString();
    }
}
